package net.csdn.business.common.domain.issue.event;

import lombok.*;
import lombok.experimental.SuperBuilder;
import net.csdn.business.common.domain.issue.IssueExt;
import net.csdn.business.common.enums.UserTypeEnum;

/**
 * @author likun
 * @date 2022/11/17 16:21
 */
@Data
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
public class AssignUserEventDto extends BaseEventDto {
    private String originAssignUser;

    private String assignUser;

    private String assignNickname;

    public AssignUserEventDto(String id, String actionUid, Long projectId, Integer serialNumber, String title, String originAssignUser, String assignUser) {
        super(id, actionUid, UserTypeEnum.USER.getType(), projectId, serialNumber, title);
        this.originAssignUser = originAssignUser;
        this.assignUser = assignUser;
    }

    public AssignUserEventDto(String id, String actionUid, Integer actionUserType, Long projectId, Integer serialNumber, String title, String originAssignUser, String assignUser, IssueExt ext) {
        super(id, actionUid, actionUserType, projectId, serialNumber, title);
        this.originAssignUser = originAssignUser;
        this.assignUser = assignUser;
        super.setExt(ext);
    }

    public static AssignUserEventDto buildChangeEvent(String id, Long projectId, String actionUid, String assignUser) {
        return AssignUserEventDto.builder()
                .id(id).projectId(projectId).actionUid(actionUid).actionUserType(UserTypeEnum.USER.getType())
                .assignUser(assignUser)
                .build();
    }

    public static AssignUserEventDto buildChangeEvent(String id, Long projectId, String actionUid, Integer actionUserType, String assignUser, IssueExt ext) {
        return AssignUserEventDto.builder()
                .id(id).projectId(projectId).actionUid(actionUid).actionUserType(actionUserType)
                .assignUser(assignUser)
                .ext(ext)
                .build();
    }
}